package com.shadow.study.excel.in;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.shadow.study.excel.entity.ExcelEntity;
import com.shadow.study.excel.in.v35.ToEntityConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;


@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ExcelVO extends ToEntityConverter<ExcelEntity> implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id;

    private String string;

    private Integer number;

    private BigDecimal decimalColumn;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime modifiedTime;

    @Override
    public ExcelEntity convert() {
        ExcelEntity entity = new ExcelEntity();
        entity.setString(string)
                .setNumber(number)
                .setDecimalColumn(decimalColumn)
                .setCreateTime(createTime)
                .setModifiedTime(modifiedTime);
        return entity;
    }
}
